#pragma once

#include <string>

#include "gl/glew.h"

#include "technique.h"
#include "EggNineScene.h"

#include "cmnBlocks.h"

#include "CImg.h"

using namespace std;
using namespace cimg_library;

namespace EggNine {

class WaveMesh : public PresentableMesh, public SimulateableMesh {
    ModelBlock::SModel          m_modelData;
    MaterialBlock::SMaterial    m_materialData;
    WaveSimBlock::WaveSimParams m_wParams;

    GLuint  m_vaoId;
    GLuint  m_vbo;
    GLuint  m_indx;
    GLuint  m_texs[5];

    const ModelBlock*       m_uniformModel;
    const MaterialBlock*    m_uniformMaterial;
    const WaveSimBlock*     m_wSimBlock;

    GLint   m_Position;
    GLint   m_TexCoords;

    int     m_fullDims;
    int     m_partDims;
    int     m_nVertices;
    float   m_dh;
    
    CImg<float> m_impulse;

    int m_baseTexIdx;

public:
    WaveMesh(int cells, float L, float c, float dt);
    ~WaveMesh();

    void Simulate(float dt, const IProgram* pTechnique);
    void Draw(const IProgram* pTechnique);
    void AttachUniforms(const UniformMap& uBlocks);
    void MapAttributes(const ProgramsMap& tMap);
    MeshPresentMethod PresentMethod() const;
    MeshPresentMethod SimulateMethod() const;
};

} // EggNine